<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function* fun(){
            console.log("开始");
            let x = yield 1;
            console.log(x);
            let y = yield 2;
            console.log(y)
            console.log(x+y);
        }
        let it = fun();

        it.next()
        // 在启动执行的时候传入6给x作为参数
        it.next(6)
        it.next(8)


    </script>
</body>
</html>